package com.ctsi.framework.common.startrun;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: zhangjw
 * @Date: 2018/11/7 15:42
 * @Description:
 */
@Configuration
public class PlatformStart implements ApplicationRunner, ApplicationContextAware {

    private static final Logger log = LoggerFactory.getLogger(StartPlatform.class);
    private static final List<IStartRun> runList = new ArrayList<>();
    private static final List<LazyStartRun> lazeRunList = new ArrayList<>();
    private static volatile boolean normalStart = true;

    private ApplicationContext applicationContext;

    /**
     * Callback used to run the bean.
     *
     * @param args incoming application arguments
     * @throws Exception on error
     */
    @Override
    public void run(ApplicationArguments args) throws Exception {

    }


    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
        ComponentFactory.setApplicationContext(applicationContext);
    }
}
